<template>
  <button type="button" @click="state.count++">count is: {{ state.count }}</button>
 
</template>

<script setup>
/* setup作用
1. 直接导入组件
*/
import Login from 'comps/Login.vue'
import { defineEmit, defineProps, reactive,useContext } from 'vue'

// 2.属性定义
const props = defineProps({
  msg: String
})
console.log(props)
// 3.获取上下文
const ctx = useContext()
console.log("ctx",ctx)

ctx.expose({
  someMethod(){
    console.log("smo message from HelloWorld")
  }
})

// 4.定义事件
const emit = defineEmit(["myClick"])

const state = reactive({ count: 0 })

const onclick = () => {
  ctx.emit('myClick')
}

// mock请求
fetch("/api/getUserInfor").then((res) => res.json()).then(res => {
  console.log("mock",res)
})
</script>

<style scoped>
a {
  color: #42b983;
}
</style>
